<?php
require_once '../include.php';
$username=$_POST['username'];
$password=md5($_POST['password']);
$verify=$_POST['verify'];
$verify1=$_SESSION['verify'];
if ($verify == $verify1) {
	# code...
	$sql = "select * from imooc_admin where username='{$username}' and password='{$password}'";
	$row = checkAdmin($sql);
	//var_dump($res);
	if ($row) {
		//如果选了一周内自动登陆
		if($autoFlag){
			setcookie("adminPassword",$row['password'],time()+7*24*3600);
			setcookie("adminName",$row['username'],time()+7*24*3600);
		}
		# code...
		$_SESSION['adminName']=$row['username'];
		$_SESSION['adminPassword']=$row['password'];
		//header("location:index.php");
		alertMes("登陆成功","index.php");
	}else{
		alertMes("登陆失败","login.php");
	}
}else{
	alertMes("验证码错误","login.php");
}